package cn.hxzy.teacher.mapper;

import cn.hxzy.common.domain.ClassTable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface ClassMapper extends BaseMapper<ClassTable> {


    /**
     * 根据班级Id修改班级名称
     *
     * @param classId
     * @param className
     * @return
     */
    @Update("UPDATE sys_class SET class_name=#{className} WHERE class_id=#{classId}")
    int updateClass(@Param("classId") Integer classId, @Param("className") String className);


    /**
     * 模糊查询班级
     *
     * @param className
     * @return
     */
    @Select("SELECT * FROM `sys_class` WHERE class_name like #{className} and create_id=#{createId}")
    List<ClassTable> selectClass(@Param("className") String className, @Param("createId") Integer createId);


    /**
     * 根据教师id查询班级id
     */
    @Select("select class_id from sys_class_teacher where teacher_id = #{teacherId}")
    List<Integer> selectClassIdByTeacherId(Integer teacherId);

    /*
     * 根据班级id查询班级信息
     * */
    @Select("select * from sys_class where class_id = #{integer}")
    ClassTable selectClassByClassId(Integer integer);

    @Select("SELECT * from sys_class")
    List<ClassTable> findAll();

    //删除中间表
    @Delete("delete from sys_class_teacher where class_id = #{classroomId} ")
    Integer deleteClassTeacher(Long classroomId);

    //删除班级
    @Delete("delete from sys_class where class_id =#{classrommId}")
    Integer deleteClass(Long classroomId);

}
